﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using Infrastructure.CloudWeb.Extensions;
using System.Configuration;
using Microsoft.Practices.Unity.Configuration;
namespace SkynetSite
{
    public class Global : System.Web.HttpApplication
    {

        void Application_Start(object sender, EventArgs e)
        {
            var container = HttpContext.Current.Application.GetContainer();
            var AspectPath = Server.MapPath("~/Config/Aspect.config");
            var AspectMap = new ExeConfigurationFileMap() { ExeConfigFilename = AspectPath };
            var AspectSection = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(AspectMap, ConfigurationUserLevel.None).GetSection("unity") as UnityConfigurationSection;
            container.LoadConfiguration(AspectSection);

            var DataAccessPath = Server.MapPath("~/Config/DataAccess.config");
            var DataAccessMap = new ExeConfigurationFileMap() { ExeConfigFilename = DataAccessPath };
            var DataAccessSection = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(DataAccessMap, ConfigurationUserLevel.None).GetSection("unity") as UnityConfigurationSection;
            container.LoadConfiguration(DataAccessSection);

            var BusinessPath = Server.MapPath("~/Config/Business.config");
            var BusinessMap = new ExeConfigurationFileMap() { ExeConfigFilename = BusinessPath };
            var BusinessSection = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(BusinessMap, ConfigurationUserLevel.None).GetSection("unity") as UnityConfigurationSection;
            container.LoadConfiguration(BusinessSection);

            var AdministracionPath = Server.MapPath("~/Config/Administracion.config");
            var AdministracionMap = new ExeConfigurationFileMap() { ExeConfigFilename = AdministracionPath };
            var AdministracionSection = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(AdministracionMap, ConfigurationUserLevel.None).GetSection("unity") as UnityConfigurationSection;
            container.LoadConfiguration(AdministracionSection);
        }

        void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown

        }

        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs

        }

        void Session_Start(object sender, EventArgs e)
        {
          

        }

        void Session_End(object sender, EventArgs e)
        {
            // Code that runs when a session ends. 
            // Note: The Session_End event is raised only when the sessionstate mode
            // is set to InProc in the Web.config file. If session mode is set to StateServer 
            // or SQLServer, the event is not raised.

        }

    }
}
